package com.ruoyi.customerSample.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;

import com.ruoyi.customerSample.domain.SampleTypeDetails;
import com.ruoyi.customerSample.service.ISampleTypeDetailsService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 样品分类保存明细Controller
 * 
 * @author lgq
 * @date 2023-05-15
 */
@RestController
@RequestMapping("/sampleType/details")
@Api(value="样品分类保存明细",tags = "样品分类保存明细接口")
public class SampleTypeDetailsController extends BaseController
{
    @Autowired
    private ISampleTypeDetailsService sampleTypeDetailsService;

    /**
     * 查询样品分类保存明细列表
     */
    @GetMapping("/list")
    @ApiOperation(value="查询样品分类保存明细列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "pageNum", value = "页数", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "pageSize", value = "每页记录数", required = true, dataType = "String"),
    })
    public TableDataInfo list(SampleTypeDetails sampleTypeDetails)
    {
        startPage();
        List<SampleTypeDetails> list = sampleTypeDetailsService.selectSampleTypeDetailsList(sampleTypeDetails);
        return getDataTable(list);
    }

    /**
     * 导出样品分类保存明细列表
     */
    @Log(title = "样品分类保存明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SampleTypeDetails sampleTypeDetails)
    {
        List<SampleTypeDetails> list = sampleTypeDetailsService.selectSampleTypeDetailsList(sampleTypeDetails);
        ExcelUtil<SampleTypeDetails> util = new ExcelUtil<SampleTypeDetails>(SampleTypeDetails.class);
        return util.exportExcel(list, "details");
    }

    /**
     * 获取样品分类保存明细详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation(value="获取样品分类保存明细详细信息")
    @ApiImplicitParam(paramType="query", name = "id", value = "主键", required = true, dataType = "String")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(sampleTypeDetailsService.selectSampleTypeDetailsById(id));
    }

    /**
     * 新增样品分类保存明细
     */
    @Log(title = "样品分类保存明细", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value="新增样品分类保存明细")
    public AjaxResult add(@ApiParam(name="样品分类保存明细",value="传入json格式",required=true)@RequestBody SampleTypeDetails sampleTypeDetails)
    {
        return toAjax(sampleTypeDetailsService.insertSampleTypeDetails(sampleTypeDetails));
    }

    /**
     * 修改样品分类保存明细
     */
    @Log(title = "样品分类保存明细", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value="修改样品分类保存明细")
    public AjaxResult edit(@ApiParam(name="样品分类保存明细",value="传入json格式",required=true)@RequestBody SampleTypeDetails sampleTypeDetails)
    {
        return toAjax(sampleTypeDetailsService.updateSampleTypeDetails(sampleTypeDetails));
    }

    /**
     * 删除样品分类保存明细
     */
    @Log(title = "样品分类保存明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value="删除样品分类保存明细")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sampleTypeDetailsService.deleteSampleTypeDetailsByIds(ids));
    }
}
